package com.yilin.tms.capital.controller;

import com.yilin.tms.capital.service.IStatisticsService;
import com.yilin.tms.core.application.ReturnData;
import com.yilin.tms.core.commons.annotation.UserTarget;
import com.yilin.tms.core.commons.base.BaseController;
import com.yilin.tms.core.entity.data.statistics.TradeRecordStatistics;
import com.yilin.tms.core.entity.data.statistics.capital.CapitalStatistics;
import com.yilin.tms.core.entity.user.UserType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/capital/statistics/")
public class StatisticsController extends BaseController {

    @Resource
    IStatisticsService statisticsService;

    /**
     * 财务支付结算待处理统计
     */
    @PostMapping(value = "getTradeRecordStatistics")
    public ReturnData<TradeRecordStatistics> getTradeRecordStatistics() {
        TradeRecordStatistics tradeRecordStatistics = statisticsService.getTradeRecordStatistics();
        return jsonView(SUCCESS_CODE, "获取成功", tradeRecordStatistics);
    }

    /**
     * 资金统计
     */
    @PostMapping(value = "getCapitalFundStatistics")
    public ReturnData<Map<String, Object>> getCapitalFundStatistics() {
        Map<String, Object> map = statisticsService.getCapitalFundStatistics(getLoginUser());
        return jsonView(SUCCESS_CODE, "获取成功", map);
    }

    /**
     * 资金统计
     */
    @PostMapping(value = "getCapitalStatistics")
    @UserTarget({UserType.adminUser, UserType.yilinUser, UserType.zoneUser, UserType.platformUser})
    public ReturnData<CapitalStatistics> getCapitalStatistics() {
        CapitalStatistics capitalStatistics = statisticsService.getCapitalStatistics(getLoginUser());
        return jsonView(SUCCESS_CODE, "获取成功", capitalStatistics);
    }

}
